<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="app">


  </div>
  <!-- 引入React依赖 -->
  <script src="../React/react.development.js"></script>
  <script src="../React/react-dom.development.js"></script>
  <script src="../React/babel.min.js"></script>

  <!-- 编写React代码 -->
  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super()
        //定义变量
        this.state = {
          isLogin: true,
        }
      }
      render() {
        const { isLogin } = this.state
        return (
          <div>
            <button onClick={() => this.loginButton()} >{isLogin ? "退出" : "登录"}</button>
            <h2 style={{ display: isLogin ? 'block' : "none" }}>你好啊，codewhy</h2>
          </div>
        )
      }

      loginButton() {
        this.setState({
          isLogin: !this.state.isLogin,
        })
      }
    }
  </script>

  <script type="text/babel">
    ReactDOM.render(<App />, document.getElementById("app"))
  </script>

</body>

</html>